
import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

/**
 * Predefined variables
 * Name = BtnExample
 * DateTime = Tue Nov 02 2021 13:54:21 GMT+0800 (中国标准时间)
 * Author = yly1234560
 * FileBasename = Btn_Example.ts
 * FileBasenameNoExtension = Btn_Example
 * URL = db://assets/scripts/Btn_Example.ts
 * ManualUrl = https://docs.cocos.com/creator/3.3/manual/zh/
 *
 */
 
@ccclass('BtnExample')
export class BtnExample extends Component {
    // [1]
    // dummy = '';

    // [2]
    // @property
    // serializableDummy = 0;

    start () {
        // [3]
    }

    // update (deltaTime: number) {
    //     // [4]
    // }



    // 添加精灵的点击事件
    callback (event: Event, customEventData: string) {

        console.log(customEventData); // foobar


        // 这里 event 是一个 Touch Event 对象，你可以通过 event.target 取到事件的发送节点
        const node = event.target as unknown as Node;
        // const button = node.getComponent(Button);
        console.log(customEventData); // foobar
        console.log(node.name); // foobar
    }
}

/**
 * [1] Class member could be defined like this.
 * [2] Use `property` decorator if your want the member to be serializable.
 * [3] Your initialization goes here.
 * [4] Your update function goes here.
 *
 * Learn more about scripting: https://docs.cocos.com/creator/3.3/manual/zh/scripting/
 * Learn more about CCClass: https://docs.cocos.com/creator/3.3/manual/zh/scripting/ccclass.html
 * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.3/manual/zh/scripting/life-cycle-callbacks.html
 */
